package com.yy.finvideoplayer.floatwindow

import android.annotation.TargetApi
import android.graphics.Outline
import android.graphics.Rect
import android.os.Build
import android.view.View
import android.view.ViewOutlineProvider

/**
 * @Description: TextureVideoViewOutlineProvider
 * @Author: yiw89
 * @CreateDate: 2025/9/1 14:48
 * @Version: 1.0
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
class TextureVideoViewOutlineProvider(radius: Float) : ViewOutlineProvider() {
    private val mRadius = radius

    override fun getOutline(view: View, outline: Outline) {
        val rect = Rect()
        view.getGlobalVisibleRect(rect)
        val leftMargin = 0
        val topMargin = 0
        val selfRect = Rect(
            leftMargin, topMargin,
            rect.right - rect.left - leftMargin, rect.bottom - rect.top - topMargin
        )
        outline.setRoundRect(selfRect, mRadius)
    }
}